package com.kaishengit.service;

import java.util.List;

import org.springframework.transaction.annotation.Transactional;

import com.kaishengit.dao.DealNoteDao;
import com.kaishengit.pojo.Deal;
import com.kaishengit.pojo.DealNote;
import com.kaishengit.pojo.User;
import com.kaishengit.util.DateUtil;
@Transactional
public class DealNoteService {
	private DealNoteDao dealNoteDao;
	
	
	public List<DealNote> findAll(){
		return dealNoteDao.findAll();
	}
	
	public void save(DealNote dealNote){
		dealNoteDao.save(dealNote);
	}


	public DealNote findById(String id) {
		return dealNoteDao.get(id);
	}
	
	//set
	public void setDealNoteDao(DealNoteDao dealNoteDao) {
		this.dealNoteDao = dealNoteDao;
	}

	public void save(DealNote dealnote, User user, Deal deal) {
		System.out.println("srhnt");
		//DealNote dealnote = new DealNote();
		
		dealnote.setCreatetime(DateUtil.getNow());
		dealnote.setState("state");
		dealnote.setUser(user);
		dealnote.setDeal(deal);
		dealNoteDao.save(dealnote);
	}

	public List<DealNote> findByDealId(String id) {
		String hql = "select h from DealNote as h where h.deal.id=? order by createtime desc";
		return dealNoteDao.find(hql, id);
	}

	public void delete(String id) {
		// TODO Auto-generated method stub
		dealNoteDao.Del(id);
	}
	
	
}
